package com.hy.demo.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.hy.demo.R;
import com.hy.frame.adapter.IAdapterListener;
import com.hy.frame.recycler.BaseAdapter;
import com.hy.frame.recycler.BaseHolder;

import java.util.List;

public class RcyAdapter extends BaseAdapter<String> {
    public RcyAdapter(@NonNull Context cxt) {
        super(cxt);
    }

    public RcyAdapter(@NonNull Context cxt, @Nullable List<String> datas) {
        super(cxt, datas);
    }

    public RcyAdapter(@NonNull Context cxt, @Nullable List<String> datas, @Nullable IAdapterListener<String> listener) {
        super(cxt, datas, listener);
    }

    @Override
    public BaseHolder getItemHolder(View v) {
        return new BaseHolder(v, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    }

    @Override
    public void bindItemData(BaseHolder holder, int position) {
        String item = getDataItem(position);
        TextView txtTitle = holder.findViewById(R.id.menu_i_txtTitle);
        txtTitle.setText(item);
        setOnClickListener(txtTitle, position);
    }

    @Override
    public int getItemLayoutId() {
        return R.layout.item_menu;
    }
}
